﻿#region Usings

using System.Collections.Generic;
using System.Text;
using System.Xml;

#endregion

namespace Kazkommertsbank.Framework.Model.Pay
{
    public class Appendix
    {
        private List<AppendixItem> _items = new List<AppendixItem>();

        public List<AppendixItem> Items
        {
            get { return _items; }
            set { _items = value; }
        }

        public string ToXmlString()
        {
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Encoding = new ASCIIEncoding();
            settings.Indent = false;
            settings.OmitXmlDeclaration = true;

            StringBuilder result = new StringBuilder();
            using(XmlWriter writer = XmlWriter.Create(result, settings))
            {
                writer.WriteStartElement("document");
                foreach(AppendixItem appendixItem in Items)
                    writer.WriteRaw(appendixItem.ToXmlString());
                writer.WriteEndElement();
            }

            return result.ToString();
        }
    }
}